# -*- coding: utf-8 -*-
"""
@Time: 2022/2/22 13:59
@Author: jins
@File: table_device.py
@Introduction: 
"""

from common.mysqlDataOperate import OperateMysql


def insert():
    device_id = 200000001
    op = OperateMysql(version='dxy')
    for i in range(202300001, 202300001 + 10):
        device_id_temp = device_id
        for j in range(0, 11):
            if j == 0:
                parent_device_id = '-1'
                root_device_id = '-1'
                device_code = str(i)
            else:
                parent_device_id = str(device_id_temp)
                root_device_id = str(device_id_temp)
                device_code = str(i) + str(j)
            device_name = 'device' + device_code
            sql = f"""INSERT INTO device_center.device
VALUES
	(
		'{device_id}',
		'{parent_device_id}',
		'{root_device_id}',
		'1',
		'{device_code}',
		'{device_code}',
		1,
		'{device_name}',
		1,
		'short_name',
		'test',
		1,
		'1',
		'mi5',
		'es',
		'1',
		'1',
		'test',
		'jins',
		'2022-9-8 14:00:00',
		'jins',
	'2022-9-8 14:00:00',
	0)
"""
            op.batch_excute(sql)
            device_id += 1
        op.commit()
    op.close()


if __name__ == '__main__':
    insert()
